package top.lixunda.ecommerce.server.good.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import top.lixunda.commerce.common.core.entity.MessageObject;
import top.lixunda.common.validate.XumValid;
import top.lixunda.ecommerce.server.business.BaseController;
import top.lixunda.ecommerce.server.business.api.entity.dto.PageConvertDTO;
import top.lixunda.ecommerce.server.good.api.controller.IOrderReviewDetailController;
import top.lixunda.ecommerce.server.good.api.entity.db.OrderReviewDO;
import top.lixunda.ecommerce.server.good.api.entity.db.OrderReviewDetailDO;
import top.lixunda.ecommerce.server.good.api.entity.dto.OrderReviewDetailQueryDTO;
import top.lixunda.ecommerce.server.good.api.entity.vo.OrderReviewConvertVO;
import top.lixunda.ecommerce.server.good.service.IOrderReviewDetailService;

import java.util.List;

/**
 * 订单评价相关查询
 *
 * @author lixunda
 * @version time:2020/3/8 10:09
 */
@Slf4j
@RestController
public class OrderReviewDetailController extends BaseController
        implements IOrderReviewDetailController {

    private final IOrderReviewDetailService orderReviewDetailService;

    @Autowired
    public OrderReviewDetailController(IOrderReviewDetailService orderReviewDetailService) {
        this.orderReviewDetailService = orderReviewDetailService;
    }

    /**
     * 根据id查询评论信息详情
     *
     * @param id 评论id
     * @return 评论信息详细信息
     */
    @Override
    public MessageObject<OrderReviewConvertVO> queryOrderReviewById(Integer id) {
        OrderReviewConvertVO vo = orderReviewDetailService.queryOrderReviewById(id);
        return getSuccessMessageObject("获取信息成功", vo);
    }

    /**
     * 根据id查询评论信息详情
     *
     * @param ids 评论id
     * @return 评论信息详细信息
     */
    @Override
    public MessageObject<List<OrderReviewConvertVO>> queryOrderReviewByIds(List<Integer> ids) {
        List<OrderReviewConvertVO> vos = orderReviewDetailService.queryOrderReviewByIds(ids);
        return getSuccessMessageObject("获取信息成功", vos);
    }

    /**
     * 分页条件查询
     *
     * @param pageConvertDTO 分页条件查询DTO
     * @return 分页数据
     */
    @Override
    public MessageObject<IPage<OrderReviewConvertVO>> queryOrderReviewByPageWrapper(
            @XumValid PageConvertDTO<OrderReviewDO, OrderReviewDetailDO, OrderReviewDetailQueryDTO> pageConvertDTO) {
        IPage<OrderReviewConvertVO> page = orderReviewDetailService.queryOrderReviewByPageWrapper(pageConvertDTO);
        return getSuccessMessageObject("获取信息成功", page);
    }
}
